/**
 * @date 11:32:59 AM
 * EducationHomeWorkController.java
 * Administrator
 * TODO
 */
package com.qs.education.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qs.education.bean.api.ResponseBean;
import com.qs.education.bean.api.ResponseListBean;
import com.qs.education.bean.beans.EducationHomeWorkResponse;
import com.qs.education.bean.beans.EducationHomeWorkStudentResponse;
import com.qs.education.bean.entity.EducationHomeWork;
import com.qs.education.bean.entity.EducationHomeWorkQuestion;
import com.qs.education.bean.entity.EducationHomeWorkStudent;
import com.qs.education.service.IHomeWorkAPPService;

/**
 * @class EducationHomeWorkController
 * @author Warren
 * @description
 * @date Nov 20, 2018
 */
@RestController
public class EducationHomeWorkController {

	@Autowired
	private IHomeWorkAPPService iHomeWorkAPPService;

	/**
	 * @author Warren
	 * @param studentId
	 * @return ResponseListBean<EducationHomeWorkStudent>
	 * @description 根据学生id查询学生的作业列表(作业本)
	 * @date Nov 20, 2018
	 */
	@RequestMapping("/homework/getListByStudentId")
	public ResponseListBean<EducationHomeWorkStudent> getListByStudentId(Long studentId) {
		ResponseListBean<EducationHomeWorkStudent> responseListBean = iHomeWorkAPPService.getListByStudentId(studentId);
		return responseListBean;
	}

	/**
	 * @author Warren
	 * @param homeworkId
	 * @return ResponseListBean<EducationHomeWorkQuestion>
	 * @description 根据作业id获得作业的所有题目
	 * @date Nov 22, 2018
	 */
	@RequestMapping("/homework/getALLQuestionByHomeWorkId")
	public ResponseListBean<EducationHomeWorkQuestion> getALLQuestionByHomeWorkId(Long homeworkId) {
		ResponseListBean<EducationHomeWorkQuestion> responseListBean = iHomeWorkAPPService
				.getALLQuestionByHomeWorkId(homeworkId);
		return responseListBean;
	}

	/**
	 * @author Warren
	 * @param hqId      作业问题标识
	 * @param studentId 学生id
	 * @param answerId  问题选项id
	 * @return ResponseBean
	 * @description
	 * @date Nov 22, 2018
	 */
	@RequestMapping("/homework/answerHomeWorkQuestion")
	public ResponseBean answerHomeWorkQuestion(Long hqId, Long studentId, Long answerId) {
		ResponseBean responseBean = iHomeWorkAPPService.answerHomeWorkQuestion(hqId, studentId, answerId);
		return responseBean;
	}

	/**
	 * @author Warren
	 * @param homeworkId
	 * @param studentId
	 * @param startTime
	 * @param endTime
	 * @return ResponseBean
	 * @description 学生提交作业
	 * @date Nov 22, 2018
	 */
	@RequestMapping("/homework/studentCommitHomeWork")

	public ResponseBean studentCommitHomeWork(Long homeworkId, Long studentId, String startTime, String endTime) {
		ResponseBean responseBean = iHomeWorkAPPService.studentCommitHomeWork(homeworkId, studentId, startTime,
				endTime);
		return responseBean;
	}
	// ----------------------------------------------------------------------------------------------------------------

	/**
	 * @Description 根据所有题目的id 以及选择的班群的id 发布作业
	 * @author Leon
	 * @date Nov 21, 2018
	 * @param questionIds 所有题目的Id
	 * @param groupIds    所有班群的id
	 * @param startTime   开始时间
	 * @return ResponseBean
	 */
	@RequestMapping("/homework/publishHomeWork")
	public ResponseBean publishHomeWork(String questionIds, String groupIds, String lessonIds, String startTime,
			String endTime, String teacherId) {
		ResponseBean response = new ResponseBean();
		response = iHomeWorkAPPService.publishHomeWork(questionIds, groupIds,lessonIds, startTime, endTime, teacherId);
		return response;
	}

	/**
	 * @Description 根据教师id查询教师发布的作业列表
	 * @author Leon
	 * @date Nov 23, 2018
	 * @param
	 * @return ResponseListBean<EducationHomeWork>
	 */
	@RequestMapping("/homework/findHomeWorkByTeacherId")
	public ResponseListBean<EducationHomeWork> findHomeWorkByTeacherId(String teacherId) {
		ResponseListBean<EducationHomeWork> homeworks = new ResponseListBean<EducationHomeWork>();
		homeworks = iHomeWorkAPPService.findHomeWorkByTeacherId(teacherId);
		return homeworks;
	}
	
	/**
	 * @Description 根据作业id 查看 作业概览
	 * @author Leon
	 * @date   Nov 26, 2018
	 * @param  
	 * @return EducationHomeWork
	 */
	@RequestMapping("/homework/findHomeWorkOverviewById")
	public EducationHomeWorkResponse findHomeWorkOverviewById(String id) {
		EducationHomeWorkResponse homeWork = new EducationHomeWorkResponse();
		homeWork = iHomeWorkAPPService.findHomeWorkOverviewById(id);
		return homeWork;
	}
	
	/**
	 * @Description 删除作业
	 * @author Leon
	 * @date   Nov 26, 2018
	 * @param  
	 * @return ResponseBean
	 */
	@RequestMapping("/homework/deleteHomeWorkById")
	public ResponseBean deleteHomeWorkById(String id) {
		ResponseBean response = iHomeWorkAPPService.deleteHomeWorkById(id);
		return response;
	}
	
	/**
	 * @Description 查看学生作业概览
	 * @author Leon
	 * @date   Nov 27, 2018
	 * @param  
	 * @return EducationHomeWorkStudent
	 */
	@RequestMapping("/homework/getStudentHomeWorkOverview")
	public EducationHomeWorkStudentResponse getStudentHomeWorkOverview(String id) {
		EducationHomeWorkStudentResponse response = iHomeWorkAPPService.getStudentHomeWorkOverview(id);
		return response;
	}
}
